{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = pd.read_csv(r\"dataset/iris.arff.csv\", header=0)\n",
    "# data.drop([\"Id\"], axis=1, inplace=True)\n",
    "data.drop_duplicates(inplace=True)\n",
    "# data[\"class\"].drop_duplicates()\n",
    "# Iris-setosa Iris-versicolor Iris-virginica\n",
    "# 名称映射为数字\n",
    "data[\"class\"] = data[\"class\"].map({\"Iris-setosa\":0, \"Iris-versicolor\":1, \"Iris-virginica\":2})\n",
    "# 筛选数据，只选择0和1\n",
    "data = data[data[\"class\"]!=2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [],
   "source": [
    "class LogisticRegression:\n",
    "    '''逻辑回归算法实现'''\n",
    "    def __init__(self, learning_rate, times):\n",
    "        '''初始化\n",
    "        \n",
    "        parameters\n",
    "        -----\n",
    "        learning_rate: float\n",
    "        times: int\n",
    "        '''\n",
    "        self.learning_rate = learning_rate\n",
    "        self.times = times\n",
    "    def sigmoid(self, z):\n",
    "        ''' sigmoid实现\n",
    "        \n",
    "        parameters:\n",
    "        -----\n",
    "        z: float  自变量： z=w.T*x\n",
    "        \n",
    "        Returns\n",
    "        -----\n",
    "        p: float, 属于[0,1]区间。s>=0.5(z>0)时，类别为1，否则为\n",
    "        '''\n",
    "        return 1.0 / ( 1.0 + np.exp(-z) )\n",
    "    def fit(self, X, y):\n",
    "        '''训练\n",
    "        Parameters:\n",
    "        X: 特征矩阵，可以是List也可以是Ndarray，形状为： [样本数量,特征数量]\n",
    "        y: 标签数组\n",
    "        '''\n",
    "        X = np.asarray(X)\n",
    "        y = np.asarray(y)\n",
    "        # 创建权重向量，初始化为0.多出来的1是截距\n",
    "        self.w_ = np.zeros(1 + X.shape[1]) # shape[0]为样本数量，shape[1]为特征数量\n",
    "        # 创建损失列表，保存每次迭代后的损失值\n",
    "        self.loss_ = []\n",
    "        for i in range(self.times):\n",
    "            z = np.dot(X, self.w_[1:]) + self.w_[0]\n",
    "            # 计算概率值(判定为1的概率值)\n",
    "            p = self.sigmoid(z)\n",
    "            # 根据逻辑回归的代价函数（目标函数或叫损失函数）计算损失值\n",
    "            # 逻辑回归的代价函数（目标函数或叫损失函数）：\n",
    "            # J(W) = - sum(yi * log(s(zi))+(1-yi)log(1-s(zi)))  \n",
    "            cost = - np.sum(y * np.log(p) + (1 - y) * np.log(1 - p))\n",
    "            self.loss_.append(cost)\n",
    "            # *****************************************************\n",
    "            # *******************重点：权重更新********************\n",
    "            # *****************************************************\n",
    "            # 调整权重值，根据公式 权重(j列) = 权重(j列) + 学习率 * sum( y - s(z)) * x(j列)\n",
    "            self.w_[0] += self.learning_rate * np.sum(y - p) * 1\n",
    "            self.w_[1:] += self.learning_rate * np.dot(X.T, y - p)\n",
    "    def predict_proba(self, X):\n",
    "        '''根据参数传递的样本，对样本数据进行预测属于某一个类别的概率\n",
    "        \n",
    "        Parameters\n",
    "        -----\n",
    "        X: 类数组类型 [ 样本数量, 特征数量]\n",
    "        \n",
    "        Return\n",
    "        -----\n",
    "        result：预测（概率值）\n",
    "        '''\n",
    "        X = np.asarray(X)\n",
    "        z = np.dot(X, self.w_[1:]) + self.w_[0]\n",
    "        p = self.sigmoid(z)\n",
    "        # 将预测结果转换为二位数组，方便后续拼接\n",
    "        p = p.reshape(-1,1)\n",
    "        # 将两个数组拼接，方向是横向拼接\n",
    "        return np.concatenate([1-p, p], axis=1) #横向拼接为为1\n",
    "    def predict(self, X):\n",
    "        '''根据参数预测样本属于哪个类别\n",
    "        \n",
    "        Parameters\n",
    "        -----\n",
    "        X: 类数组类型： [样本数量，特征数量]. 带预测样本特征\n",
    "        \n",
    "        Return\n",
    "        -----\n",
    "        返回属于哪个类别\n",
    "        '''\n",
    "        return np.argmax(self.predict_proba(X), axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.0"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "t1 = data[data[\"class\"]==0]\n",
    "t2 = data[data[\"class\"]==1]\n",
    "t1 = t1.sample(len(t1), random_state=0)\n",
    "t2 = t2.sample(len(t2), random_state=0)\n",
    "train_X = pd.concat([t1.iloc[:40,:-1], t2.iloc[:40,:-1]], axis=0)\n",
    "train_y = pd.concat([t1.iloc[:40,-1], t2.iloc[:40,-1]], axis=0)\n",
    "test_X = pd.concat([t1.iloc[40:,:-1], t2.iloc[40:,:-1]], axis=0)\n",
    "test_y = pd.concat([t1.iloc[40:,-1], t2.iloc[40:,-1]], axis=0)\n",
    "\n",
    "# 鸢尾花的特征列都在同一个数量级，我们可以不用标准化处理\n",
    "lr = LogisticRegression(learning_rate=0.01, times=20)\n",
    "lr.fit(train_X, train_y)\n",
    "# lr.predict_proba(test_X)\n",
    "result = lr.predict(test_X)\n",
    "# 计算准确性\n",
    "accuracy = np.sum(result==test_y) / len(test_y)\n",
    "display(accuracy)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib as mpl\n",
    "import matplotlib.pyplot as plt\n",
    "mpl.rcParams['font.family'] = 'SimHei'\n",
    "mpl.rcParams['axes.unicode_minus'] = False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAAETCAYAAAA23nEoAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAcfklEQVR4nO3de5xcZZ3n8c83V9KdGII0QRhCyA6L3B1pQ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mZkBDgQzM8scCGZmBjgQzMws+/91pIkiQSS9jwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 绘制预测值\n",
    "plt.plot(result, 'ro',ms=15, label=\"预测值\") # ms指定圆圈大小\n",
    "plt.plot(test_y.values, 'go', label=\"预测值\") # pandas读取时serise类型，我们需要转为ndarray\n",
    "plt.title('逻辑回归预测')\n",
    "plt.xlabel('样本序号')\n",
    "plt.ylabel('预测值')\n",
    "plt.show()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(0, 0.5, '损失值loss')"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAEECAYAAAAh5uNxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3de3xddZnv8c+T+61Nekl6o20solIsDDRBUHDAgh49w6jQjjPW23E8nZcKIy+Px0HrOSMzBo/HG+p4mY7MHOdY9aCjaFEuihcqgragWBUQUpoWSKAladokba7P+WPtHXZ29k72bvbae6+d7/v12q/urKzLk0XYT36/3/o9P3N3RERk/ikrdAAiIlIYSgAiIvOUEoCIyDylBCAiMk8pAYiIzFNKACIi81RFoQPI1NKlS721tbXQYYiIRMr9999/xN2bU30vMgmgtbWVvXv3FjoMEZFIMbOudN9TF5CIyDylBCAiMk8pAYiIzFNKACIi85QSgIjIPKUEELKd+3bSemMrZdeX0XpjKzv37Sx0SCIiQIQeA42inft2sm3XNoZGhwDo6u9i265tAGzdsLWQoYmIqAUQp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z+DLjN3b+RsO/VZvZXwIJY8a4vEvT1X0BQ5fHfCOr6Pw18y8zemGp8QSQMKgYn85KZlRXieXszq3D3sdh7A8o8WHAEMzPX/5CSR0oAIiLzlAaBRUTmKSUAEZF5SglARGSeUgIQEZmnlABEROap/w9/MBvc+MybNwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 绘制目标函数的损失值\n",
    "plt.plot(range(1,lr.times+1), lr.loss_, 'go-')\n",
    "plt.xlabel('迭代次数')\n",
    "plt.ylabel('损失值loss')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
